package com.lee.api.client;

import cn.hutool.db.PageResult;
import com.lee.common.model.AppResult;
import com.lee.common.model.Article;
import com.lee.common.model.EditorJson;
import com.sun.istack.internal.NotNull;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;


@FeignClient(value = "article-service", path = "/article")
public interface ArticleClient {

    @GetMapping("/getlistbypage")
    public AppResult<PageResult> getListByPage(@ApiParam("板块Id") @RequestParam(value = "boardId",required = false) Long boardId,
                                               @ApiParam("页号") @RequestParam(value = "pIndex",defaultValue = "1",required = false) Integer pIndex,
                                               @ApiParam("每页大小") @RequestParam(value = "pSize",defaultValue = "10",required = false) Integer pSize);


    @PostMapping("/create")
    public AppResult create (@ApiParam("板块Id") @RequestParam("boardId") @NotNull Integer boardId,
                             @ApiParam("帖子标题") @RequestParam("title") @NotNull String title,
                             @ApiParam("帖子内容") @RequestParam("content") @NotNull String content);

    @GetMapping("/getAllBoardList")
    public AppResult<List<Article>> getAllBoardList(
            @ApiParam("板块Id") @RequestParam(value = "boardId",required = false) Long boardId);

    @GetMapping("/details")
    public AppResult<Article> getDetails(@ApiParam("帖子Id") @RequestParam("id") @NotNull Long id);

    @PostMapping("/modify")
    public AppResult modify(@RequestParam("id") Long id,
                            @RequestParam("title") String title,
                            @RequestParam("content") String content);

    @PostMapping("/thumbsUp")
    public AppResult thumbsUpById(@RequestParam("id") Long id);

    @PostMapping("/delete")
    public AppResult deleteById(@RequestParam("id") @NotNull Long id);

    @GetMapping("/getAllByUserId")
    public AppResult<List<Article>> getAllByUserId(@RequestParam(value = "userId",required = false) Long id);

    @PostMapping("/editormdImages")
    public EditorJson editormdImages(
            @RequestPart("editormd-image-file") MultipartFile file);

    void addOneArticleReplyCountById(Long articleId);

    Article selectById(Long articleId);
}
